package service

import (
	"context"
	coreV1 "k8s.io/api/core/v1"
	metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
)

func GetNodeList(clientSet *kubernetes.Clientset) (nodeList *coreV1.NodeList, err error) {
	nodeList, err = clientSet.CoreV1().Nodes().List(context.TODO(), metaV1.ListOptions{})
	if err != nil {
		return nodeList, err
	}
	return nodeList, nil
}

func GetNode(clientSet *kubernetes.Clientset, nodeName string) (nodeInfo *coreV1.Node, err error) {
	nodeInfo, err = clientSet.CoreV1().Nodes().Get(context.TODO(), nodeName, metaV1.GetOptions{})
	if err != nil {
		return nodeInfo, err
	}
	return nodeInfo, nil
}
